from db import db
import datetime

class Info(db.Model):
    __tablename__ = 'info'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    age = db.Column(db.Integer,nullable=False)
    gender = db.Column(db.String(255), nullable=False)
    description = db.Column(db.String(255), nullable=False)
    left_fundus = db.Column(db.String(255), nullable=False)
    right_fundus = db.Column(db.String(255), nullable=False)
    result = db.Column(db.Integer, nullable=False)
    create_time = db.Column(db.DateTime, default=datetime.datetime.now)
    username = db.Column(db.String(255), nullable=False)

    def __init__(self, age, gender, description, left_fundus, right_fundus, result,username):
        self.age = age
        self.gender = gender
        self.description = description
        self.left_fundus = left_fundus
        self.right_fundus = right_fundus
        self.result = result
        self.username = username

    def to_dict(self):
        return {
            "id": self.id,
            "age": self.age,
            "gender": self.gender,
            "description": self.description,
            "leftFundus": self.left_fundus,
            "rightFundus": self.right_fundus,
            "result": self.result,
            "createTime": self.create_time,
            "username": self.username
        }